#!/bin/sh

# Clean up any symbolic link to The Grand 3.vst3, that might have been created by a previous version of this installer.
if [ -L "/Library/Audio/Plug-Ins/VST/The Grand 3/The Grand 3.vst" ]; then
	echo "A symbolic link /Library/Audio/Plug-Ins/VST/The Grand 3/The Grand 3.vst exists. Deleting it."
	rm "/Library/Audio/Plug-Ins/VST/The Grand 3/The Grand 3.vst"
fi

# make sure, that there's a subdirectory inside the VST location
if [ ! -e "/Library/Audio/Plug-Ins/VST/The Grand 3/The Grand 3.vst" ]; then
	mkdir -p "/Library/Audio/Plug-Ins/VST/The Grand 3/The Grand 3.vst"
fi

# Check, if an installation of the VST3-plugin (which can behave as a VST plugin) exists.
if [ -d "/Library/Audio/Plug-Ins/VST3/Steinberg/The Grand 3.vst3" ]; then
	# Copy the VST3 plugin to the VST location. A symbolic link instead of the copy wouldn't work, because some
	# hosts (e.g. Ableton Live) don't support a link in the VST location.
	cp -Rp "/Library/Audio/Plug-Ins/VST3/Steinberg/The Grand 3.vst3/" "/Library/Audio/Plug-Ins/VST/The Grand 3/The Grand 3.vst/"
fi
